/* BEGIN_COMMON_COPYRIGHT_HEADER
 * (c)LGPL2+
 *
 * LXQt - a lightweight, Qt based, desktop toolset
 * https://lxqt.org
 *
 * Copyright: 2015 LXQt team
 * Authors:
 *  Balázs Béla <balazsbela[at]gmail.com>
 *  Paulo Lieuthier <paulolieuthier@gmail.com>
 *
 * This program or library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * END_COMMON_COPYRIGHT_HEADER */
#ifndef STATUSNOTIFERSCROLLAREA_H
#define STATUSNOTIFERSCROLLAREA_H
#include <QScrollBar>
#include <QScrollArea>
#include <QWidget>
#include "../panel/iukuipanelplugin.h"
#include "../panel/common/ukuigridlayout.h"
#include "../panel/pluginsettings.h"
#include "statusnotifierwidget.h"
#include "statusnotifierbutton.h"
#include "statusnotifierwatcher.h"
#include "statusnotifier_storagearrow.h"

class StatusNotiferScrollArea : public QScrollArea
{
    Q_OBJECT
public:
    StatusNotiferScrollArea(IUKUIPanelPlugin *plugin, QWidget *parent = 0);
    ~StatusNotiferScrollArea();

protected:
    void wheelEvent(QWheelEvent* event);

public Q_SLOTS:
    void realign();
    void itemAdded(QString serviceAndPath);
    void itemRemoved(const QString &serviceAndPath);

private Q_SLOTS:
    void switchButtons(StatusNotifierButton *button1, StatusNotifierButton *button2);
    void btnAddButton(QString button);

private:
    void saveSettings(QString button1,QString button2);
    QList<QStringList> readSettings();
    void resetLayout();
    void exchangeHideAndShow();

private:
    IUKUIPanelPlugin *m_plugin;
    QWidget *m_parent;
    QWidget *m_statusNotifierWidget;
    QGSettings *m_btnIsShowgsettings;
    UKUi::GridLayout *m_layout;
    StatusNotifierWatcher *m_watcher;

    QHash<QString, StatusNotifierButton*> m_services;
    QMap<QString,StatusNotifierButton*> m_showButtons;
    QMap<QString,StatusNotifierButton*> m_hideButtons;
    QMap<QString,StatusNotifierButton*> m_allButtons;

    QList<StatusNotifierButton*> m_statusNotifierButtons;
    StatusNotifierStorageArrow *m_arrowBtn;
    QGSettings *m_gsettings;
};

#endif // STATUSNOTIFERSCROLLAREA_H
